import * as sdk from './fetch';

const controllerName = 'OpenDoorController';

/**
 *
 * 查询用户人脸数据
 *
 */
async function findUserInfo(params): Promise<BaseResponseString> {
  let result = await sdk.rzget(
    `apiUser/findUserInfo?id=${params.id}&communityId=${params.communityId}`,

    {},
  );
  return result;
}
/**
 *
 * 人脸信息采集
 *
 */
async function uploadUserPicture(params): Promise<BaseResponseString> {
  let result = await sdk.rzpost(
    'apiUser/uploadUserPicture',

    {
      ...params
    },
  );
  return result;
}
/**
 *
 * 查询单元门接口
 *
 */
async function findUnitName(params): Promise<BaseResponseString> {
  let result = await sdk.rzget(
    `apiUser/findUnitName?houseId=${params.houseId}`,

    {},
  );
  return result;
}
/**
 *
 * 查询大门接口
 *
 */
async function findGateList(params): Promise<BaseResponseString> {
  let result = await sdk.rzget(
    `apiUser/findGateList?communityId=${params.communityId}`,

    {},
  );
  return result;
}
/**
 *
 * 远程开门
 *
 */
async function openDoorById(params): Promise<BaseResponseString> {
  let result = await sdk.rzpost(
    'equipment/openDoorById',

    {
      ...params
    },
  );
  return result;
}

export default {
  findUserInfo,
  uploadUserPicture,
  findUnitName,
  findGateList,
  openDoorById
};

/**
 * 正常请求返回
 */
export interface BaseResponseString {
  /**
   * 结果码
   */
  code: string;
  /**
   * 内容
   */
  data?: {
    [k: string]: any;
  };
  /**
   * 错误内容
   */
  errorData?: {
    [k: string]: any;
  };
  /**
   * 状态
   */
  success?: boolean;
  /**
   * 消息内容
   */
  message?: string;
  [k: string]: any;
}
